package rpc

import (
	"github.com/golang/protobuf/proto"
	. "leaf/core/msg"
)

type IRpcConnect interface {
	OnRpcDisconnect(uniqueid string)
}

type RpcType uint8

type RpcCall struct {
	Msg  *PMsg
	Done chan *RpcCall
}

func NewRpcCall(method string, id uint32, request proto.Message, reply proto.Message) *RpcCall {
	c := new(RpcCall)
	c.Msg = new(PMsg)
	c.Msg.Request = NewRpcMessage(method, id, request)
	if id != 0 {
		c.Msg.Reply = NewRpcMessage(method, id, reply)
	}
	c.Done = make(chan *RpcCall, 1)
	return c
}
